package com.evolved.automata.android.bots;

public class ControlMessage {
	private float rawX=0;
	private float rawY=0; // Y being approximately 9.81 m/s^2 means robot is upright
	private float rawZ=0; // Z of zero means robot is upright.  Z axis is inverted so that 
						  // when the robot is leaning forward and the face of the phone is
						  // forward then the z acceleration increases with degree of forward
						  // tilt
	
	private float angleRad=0;
	private float angleDeg=0;

	private float j_DeltaTSeconds=.2F;
	private float tolerance=0.00001F;
	
	
	
	public float GetAngleRad()
	{
		
		if (Math.abs(rawY)<tolerance)
			return (float)(Math.signum(rawZ)*Math.PI/2);
		else
			return (float)Math.atan(rawZ/rawY);
	}
	
	public float GetAngleDeg()
	{
		return (float)(GetAngleRad()*180/Math.PI);
	}
	
	
	
	public void setX(float x)
	{
		rawX=x;
	}
	
	
	public void setY(float y)
	{
		rawY=y;
	}
	
	public void setZ(float z)
	{
		rawZ=-1*z;
	}
	
	public void setDT(float deltaTMilli)
	{
		j_DeltaTSeconds=deltaTMilli/1000;
	}
	
	public float getDeltaT()
	{
		return j_DeltaTSeconds;
	}

}
